//Debounce MR
float lastTime = 0;
int lastVal = 1;
int MRval = HIGH;
const int ddelay = 10;

int MR(){
  int val =0;
  val = digitalRead(sensMR);

  if (val != lastVal){lastTime = millis();}  
  if ((millis() - lastTime) > ddelay){MRval = val;}
  lastVal = val;
  return MRval;
}

int count = 0;

int sens(){  //1= right; 2= MR; 3 =ML; 4=Left
  int val = 0;
  int res = 0;

  val = digitalRead(sensRR);
  if(val == LOW) {res = 1;}
  val = MR();
  if(val == LOW) {res = 2;}
  val = digitalRead(sensML);
  if(val == LOW) {res = 3;}
  val = digitalRead(sensLL);
  if(val == LOW) {res = 4;} 
  
  /*int diff=millis()-lastLog;
  if(diff>=200){
    Serial.println(res, DEC);
    delay(2);
    lastLog=millis();
  }*/
  delay(50);
  count++;
  if((millis()-startTime)>1000){
    Serial.print("Sens: ");
    Serial.println(count);
    delay(1);
    count=0;
    startTime=millis();
  }
  return res;
}

